package org.hxd.employee.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.hxd.pojo.Dept;
import org.hxd.pojo.Employee;
import org.hxd.pojo.Job;
import org.hxd.units.PageModel;

import java.util.List;

public interface EmployeeDao {
    //查询职位个数
    @Select("select id,name,remark from job_inf")
    List<Job> findAllJob();
    //查询部门个数
    @Select("select id,name,remark from dept_inf")
    List<Dept> findAllDept();
    //（条件）查询员工信息
    List<Employee> findEmployee(@Param("employee") Employee employee,@Param("pageModel") PageModel pageModel);
    //查询员工信息个数
    int findEmployeeCount(Employee employee);
    //根据id查找员工
    Employee findEmployeeByid(int id);

    @Update("update employee_inf set " +
            "name=#{name},card_id=#{card_id},sex=#{sex},job_id=#{job.id},education=#{education}," +
            "email=#{email},phone=#{phone},party=#{party},qq_num=#{qq_num},address=#{address}," +
            "post_code=#{post_code},birthday=#{birthday},race=#{race},speciality=#{speciality}," +
            "hobby=#{hobby},remark=#{remark},dept_id=#{dept.id},tel=#{tel} " +
            "where id = #{id}")
    int modifyEmployee(Employee employee);

    //参数矫正，为写动态sql做准备
    int removeEmployee(@Param("ids") Integer[] ids);

    @Insert("insert into employee_inf (" +
            "name,card_id,sex,job_id,education,email,phone,tel,party,qq_num," +
            "address,post_code,birthday,race,speciality,hobby,remark,dept_id) " +
            "values(#{name},#{card_id},#{sex},#{job.id},#{education},#{email},#{phone},#{tel},#{party},#{qq_num}," +
            "#{address},#{post_code},#{birthday},#{race},#{speciality},#{hobby},#{remark},#{dept.id})")
    int addEmployee(Employee employee);
}
